<template>
<!--index.wxml-->

  <view class="container">
    
    <!-- <i-cell-group style="width:100%;">
        <i-cell v-for="(item, index) in list" :key="index" :title="item.order_sn" :label="item.create_at" :value="item.order_amount + '元'"></i-cell>
       
    </i-cell-group> -->
	<view class="list" v-for="(item,index) in list" @click="toStatus(item.id,item.cusdevice_no,item.status)">
		<view class="flex-row justify-between ">
			<view class="time">{{item.create_at}}</view>
			<view class="order-sn">{{item.order_sn}}</view>
		</view>
		<view class="flex-row justify-between">
			<view class="store-name flex-row items-center">
				<image class="store-img" src="https://shops.cg500.com/static/aijiu/dianpu@2x.png" mode=""></image>
				<text class="store-text">{{item.name}}</text>
			</view>
			<view class="status">
				<text class="cancel" v-if="item.status == -1">已取消</text>
				<text class="no-pay" v-if="item.status == 0">待支付</text>
				<text class="using" v-if="item.status == 1">进行中</text>
				<text class="complete" v-if="item.status == 2">已完成</text>
				<text class="return-money" v-if="item.status == 3">已退款</text>
			</view>
		</view>
		<view class="bottom flex-row justify-end">
			<view class="order-amount">
				-{{item.order_amount}}
			</view>
		</view>
		
	</view>
  </view>
</template>

<script>
//index.js
const app = getApp().globalData;
import iCellGroup from "../../dist/cell-group/index";
import iCell from "../../dist/cell/index";

export default {
  data() {
    return {
      background: ["/static/images/agent_img01599810087.jpeg", "/static/images/idimg01599807828.jpeg", "/static/images/idimg11599810002.jpeg"],
      indicatorDots: true,
      vertical: false,
      autoplay: false,
      interval: 2000,
      duration: 500,
	  list:[],
	  page: 1,
	  total: 0
    };
  },

  components: {
    iCellGroup,
    iCell
  },
  props: {},
  onLoad: function () {
	  this.getorder()
  },
  onReachBottom() {
  	console.log('触底了')
	if(this.page < this.total) {
		this.page++
		this.getorder()
	}else {
		uni.showToast({
			title: '暂无更多数据',
			icon: 'none'
		})
	}
  },
  methods: {
	  toStatus(orderId, cusdeviceNo,status) {
		  if(status == 1){
			  uni.navigateTo({
			  	url: '/pages/shop/equipmentStatus/index?orderId=' + orderId + '&enterType=2'
			  })
		  }
	  	
	  },
	  getorder: function () {
	    var _this = this;
	    let user_id = uni.getStorageSync('userId')
	    uni.request({
	      url: app.post_url + '/aijiu/api.Order/orderList',
	      //仅为示例，并非真实的接口地址
	      data: {
	       uid : user_id,
		   page: this.page
	      },
	      method: 'post',
	  
	      success(res) {
			_this.list = [..._this.list,...res.data.data.list]
			_this.total = res.data.data.page.pages
			// if(_this.page == 1){
				
			// }
	        // _this.setData({
	        //   list: res.data.data.data,
	        //   num: res.data.data.data.length
	        // });
	        console.log(_this.list);
	      }
	  
	    });
	  },
    handleChange({
      detail
    }) {
      console.log(detail);
    }

  }
};
</script>
<style>
@import "./index.css";
</style>